package com.newtype.meeting.client.model;

import javax.jdo.annotations.Extension;
import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.extjs.gxt.ui.client.data.BaseModel;
import com.newtype.meeting.shared.DepartmentTreeDTO;

/**
 * 部门实体类
 * @author 汪恭泽
 * Jun 17, 2011 4:17:45 PM
 */
@PersistenceCapable(identityType = IdentityType.APPLICATION, detachable = "true")
public class Department extends BaseModel {
	private static final long serialVersionUID = 5395680244304869451L;

	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	@Extension(vendorName = "datanucleus", key = "gae.encoded-pk", value = "true")
	private String id; //ID
	@Persistent
	private String deptName;//部門名稱
	@Persistent
	private String parentDeptID;//部門父ID
	@Persistent
	private Integer isExpand;//是否展開
	@Persistent
	private Integer isEnabled;//是否启用
	@Persistent
	private Integer sortID;//部門排序
	@Persistent
	private Integer deptDegree;//部門等級
	@Persistent
	private String deptBoss;//部門主管
	@Persistent
	private String jobTitle;//職位名稱
	@Persistent
	private String deptGroup;

	public Department() {
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getDeptName() {
		return deptName;
	}

	public void setDeptName(String deptName) {
		this.deptName = deptName;
	}

	public String getParentDeptID() {
		return parentDeptID;
	}

	public void setParentDeptID(String parentDeptID) {
		this.parentDeptID = parentDeptID;
	}

	public Integer getIsExpand() {
		return isExpand;
	}

	public void setIsExpand(Integer isExpand) {
		this.isExpand = isExpand;
	}

	public Integer getIsEnabled() {
		return isEnabled;
	}

	public void setIsEnabled(Integer isEnabled) {
		this.isEnabled = isEnabled;
	}

	public Integer getSortID() {
		return sortID;
	}

	public void setSortID(Integer sortID) {
		this.sortID = sortID;
	}

	public Integer getDeptDegree() {
		return deptDegree;
	}

	public void setDeptDegree(Integer deptDegree) {
		this.deptDegree = deptDegree;
	}

	public String getDeptBoss() {
		return deptBoss;
	}

	public void setDeptBoss(String deptBoss) {
		this.deptBoss = deptBoss;
	}

	public String getJobTitle() {
		return jobTitle;
	}

	public void setJobTitle(String jobTitle) {
		this.jobTitle = jobTitle;
	}

	public String getDeptGroup() {
		return deptGroup;
	}

	public void setDeptGroup(String deptGroup) {
		this.deptGroup = deptGroup;
	}

	public DepartmentTreeDTO toLightTreeDTO() {
		return new DepartmentTreeDTO(getId(), getDeptName());
	}

	public void updateProperties() {
		set("id", getId());
		set("deptName", getDeptName());
		set("parentDeptID", getParentDeptID());
		set("isExpand", getIsExpand());
		set("isEnabled", getIsEnabled());
		set("sortID", getSortID());
		set("deptDegree", getDeptBoss());
		set("jobTitle", getJobTitle());
		set("deptGroup", deptGroup);
	}

	public void updateObject() {
		setDeptName((String) get("deptName"));
		setParentDeptID((String) get("parentDeptID"));
		setIsEnabled((Integer) get("isEnabled"));
		setIsExpand((Integer) get("isEnabled"));
		setSortID((Integer) get("sortID"));
		setDeptBoss((String) get("deptBoss"));
		setJobTitle((String) get("jobTitle"));
		setDeptGroup((String) get("deptGroup"));
	}
}
